/*
 * Copyright (c) 2006, 2023, webrx.cn All rights reserved.
 *
 */

package cn.webrx;

/**
 * <p>Project: jse2303 - For4
 * <p>Powered by webrx On 2023-07-11 15:30:38
 * <p>描述：<p>
 *
 * @author webrx [webrx@126.com]
 * @version 1.0
 * @since 17
 */
public class ForEachDemo {
    public static void main(String[] args) {
        //数组String[] 一维数组
        String[] ls = new String[]{"aa", "bb", "cc", "dd"};
        //遍历数组方式一 顺序
        for (int i = 0; i < ls.length; i++) {
            System.out.printf("ls[%d] = %s%n", i, ls[i]);
        }

        //遍历数组方式二 倒序
        for (int i = ls.length - 1; i >= 0; i--) {
            System.out.printf("ls[%d] = %s%n", i, ls[i]);
        }


        //遍历数组方式三 快速 增强 的for循环语句
        //for each 语句
        for (String s : ls) {
            System.out.println(s);
        }
    }
}
